package com.example.gesture.Scrollable

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.rememberScrollableState
import androidx.compose.foundation.gestures.scrollable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp


@Composable
fun ScrollableDemo() {
    var offset by remember {
        mutableStateOf(0f)
    }

    Box(
        modifier = Modifier
            .size(200.dp)
            .background(Color.LightGray)
            .scrollable(
                orientation = Orientation.Vertical,
                state = rememberScrollableState { delta ->
                    offset += delta
                    delta
                }
            ),
        contentAlignment = Alignment.Center
    ) {
        Text(text = offset.toString())
    }
}